package oms.service;

import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import oms.dao.ItemDAO;
import oms.entities.Item;
import oms.entities.User;


@Service
public class ItemServiceImpl implements ItemService {

		@Autowired
		private ItemDAO itemDAO;
	
		@Transactional
		public void createItem(Item item) {
			
				itemDAO.createItem(item);
		}

		@Transactional
		public void updateItem(Long itemId) {
		
				itemDAO.updateItem(itemId);
		}

		@Transactional
		public Item getItemByName(String name) {
		
				return itemDAO.getItemByName(name);
		}

		@Transactional
		public Item getItemByDescription(String description) {
		
				return itemDAO.getItemByDescription(description);
		}

		@Transactional
		public void deleteItem(Long itemId) {
				
				itemDAO.deleteItem(itemId);
		}

		@Transactional
		public List<Item> itemsList() {
		
				return itemDAO.itemsList();
		}

		@SuppressWarnings("rawtypes")
		@Transactional
		public Collection getItemsByUserOrder(User user) {
		
			return itemDAO.getItemsByUserOrder(user);
		}
}